//
//  IVCSSDK.h
//  ivcs_ios_demo
//
//  Created by zealcomm user on 2020/10/21.
//  Copyright © 2020 zealcomm user. All rights reserved.
//
#import <Foundation/Foundation.h>

//! Project version number for IvcsCustomer.
FOUNDATION_EXPORT double IvcsCustomerVersionNumber;

//! Project version string for IvcsCustomer.
FOUNDATION_EXPORT const unsigned char IvcsCustomerVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <IvcsCustomer/PublicHeader.h>

#import <Foundation/Foundation.h>
#import <AVFoundation/AVCaptureDevice.h>
#import <IVCS/IVCS.h>
#import "IvcsCustomerDelegate.h"

NS_ASSUME_NONNULL_BEGIN

// 媒体类型
//typedef NS_OPTIONS(NSInteger, MediaType) {
//    MediaTypeUnknown = 0,
//    MediaTypeAudio = 1 << 0,
//    MediaTypeVideo = 1 << 1,
//};

@interface IvcsCustomer : NSObject

@property (nonatomic,strong) id<IvcsCustomerDelegate> delegate;

declareSingleInstance(Customer)

/// 访客初始化并连接服务
/// @param serviceUrl 账号系统的后台地址
/// @param name 访客登录用户名
/// @param password 访客登录密码
/// @param org 访客所属机构名
/// @param mediaOptions options 传入视频设置参数   {@"maxBitrate":@"",@"rate":@"",@"width":@"",@"height":@""}
///   maxBitrate：2000、1500、1000、768、512、384...//码率
///   rate：15,24,30,60//帧率
///   width: 640,480,720,1080//视频分辨率宽
///   height: 480,640,1280,1920//视频分辨率高
/// @param onSuccess 初始化成功，返回用户基本信息
/// @param onFailure 初始化失败，返回错误信息
/// 1001：用户不存在
/// 1101：网络请求鉴权失败
/// 1003：用户登录密码错误
/// 1104：用户账号失效无法登录
/// 500：api请求失败
-(void)initWithServiceUrl:(NSString *)serviceUrl name:(NSString *)name password:(NSString *)password org:(NSString *)org mediaOptions:(NSDictionary *__nullable)mediaOptions onSuccess:(void (^)(ZcoModelUserInfo *userInfo))onSuccess  onFailure:(void (^)(NSError *error))onFailure;

/// 发起呼叫
/// @param serviceId 场景ID
/// @param userData 用户数据 => userData,随路数据
/// eg: @{@"service":@""}
/// @param type 视频类型 audio video audio- video video- audio
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)requestSession:(NSInteger)serviceId withUserData:(NSDictionary *)userData type:(NSString *)type onSuccess:(void (^)(ZcoModelSessionInfo *sessionInfo))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 退出会话
/// @param reason 退出原因
///  eg: @{@"reason":@""}
/// @param onSuccess onSuccess 成功
/// @param onFailure onFailure  失败
-(void)quitSessionWithReason:(NSString *)reason onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 音视频加入会话
/// @param label 需要渲染的本地音视频标签
/// @param view 用于显示音视频的 view
/// @param onSuccess 成功，返回本端音视频
/// @param onFailure 失败
-(void)startVideoWithLabel:(nonnull NSString *)label callMediaType:(NSString *)type andRenderView:(IRTCMTLVideoView *)view onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 发布屏幕共享
/// @param label  需要渲染的屏幕共享的音视频标签
/// @param view 用于显示屏幕共享音视频的 view
/// @param onSuccess 成功，返回本端屏幕共享音视频
/// @param onFailure 失败
-(void)screenShare:(NSString *)label andRenderView:(IRTCMTLVideoView *)view onSuccess: (void (^)(void))onSuccess onFailure:(void (^)(NSError * _Nonnull))onFailure;

///stopScreenShare 停止屏幕共享
-(void)stopScreenShare;

/// 订阅并渲染远端音视频
/// @param label  需要渲染的音视频标签
/// @param view 渲染的控件
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)renderStreamWithLabel:(nonnull NSString *)label renderView:(NSObject<IRTCVideoRenderer>*)view onSuccess:(void (^)(void))onSuccess  onFailure:(void (^)(NSError *error))onFailure;

/// 绑定特定音视频（已订阅或本地音视频）到 view
/// @param label 音视频标签
/// @param view 渲染的控件
///  ？？？屏幕共享流的绑定或引导框的绑定
-(void)attachStreamWithLabel:(nonnull NSString *)label renderView:(NSObject<IRTCVideoRenderer> *)view;

/// 从 view 上解除特定 label 的音视频
/// @param label 音视频标签
/// @param view 渲染的控件
///  ？？？应用于屏幕共享流的解绑或引导框的解绑
-(void)detachStreamWithLabel:(nonnull NSString *)label renderView:(NSObject<IRTCVideoRenderer> *)view;

/// 切换摄像头
- (void)switchCameraOnSuccess:(nullable void (^)(void))onSuccess onFailure:(nullable void (^)(NSError * _Nonnull))onFailure;

/// 停止本地视频的声音/视频画面推送
/// @param type audio/video
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)muteWithMediaType:(NSString *)type onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 恢复本地视频的声音/视频画面推送
/// @param type audio/video
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)unmuteWithMediaType:(NSString *)type onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 分享url资源文件给对方
/// @param type 资源类型 ['doc','pic','video','aduio','page','paper']
/// @param url 资源地址
/// @param name 资源名字
/// @param roles 接受⽂件的⽤户，string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type resourceUrl:(NSString *)url resourceName:(NSString *)name toRoles:(NSString *)roles onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 分享资源文件
/// @param type 文件类型  ['doc','pic','video','aduio','page','paper']
/// @param uploadUrl 上传的url
/// @param fileData  ⽂件对象 { name: ⽂件名称(String), size: ⽂件⼤⼩(Number), url: ⽂件地址(String) }
/// @param fileName 文件名
/// @param mimeType 文件类型
/// @param roles 接受⽂件的⽤户，string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type uploadUrl:(NSString *)uploadUrl fileData:(NSData *)fileData  fileName:(NSString *)fileName mimeType:(NSString *)mimeType toRoles:(NSString *)roles onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 发送自定义消息
/// @param data 消息内容
/// @param roles 发送给角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendCustomMessage:(id)data toRoles:(NSString * __nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError *error))onFailure;

/// 发送文本消息
/// @param data 消息内容
/// @param roles 发送给角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendTextMessage:(NSString *)data toRoles:(NSString * __nullable)roles onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 发送消息确认
/// @param data 消息确认的信息体
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendMessageConfirmation:(ZcoModelConfirmData *)data toRoles:(NSString * __nullable)roles onSuccess:(void (^ __nullable)(void))onSuccess onFailure:(void (^ __nullable)(NSError *error))onFailure;

/// 发送截屏消息
/// @param imageUrl 图片的url地址
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendSnapshotMessage:(NSString *)imageUrl toRoles:(NSString * __nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^ __nullable)(NSError * _Nonnull error))onFailure;

/// 发送表单消息
/// @param data 消息内容
/// @param roles 发送给角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendFormData:(NSDictionary *)data toRoles:(NSString * __nullable)roles onSuccess:(void (^)(void))onSuccess onFailure:(void (^)(NSError *error))onFailure;

/// 地理位置响应
/// @param locationInfo 地理位置信息 获取地理位置成功/失败
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)locationResponse:(ZcoModelCMD *)locationInfo to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 扫码接受
/// @param scanCodeInfo 扫码响应数据
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)scanCodeAccept:(ZcoModelCMD *)scanCodeInfo to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

// 扫码拒绝
/// @param scanCodeInfo 扫码响应数据
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)scanCodeRefuse:(ZcoModelCMD *)scanCodeInfo to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 签名响应
/// @param handwritingInfo 手写签名数据
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)handwritingResponse:(ZcoModelCMD *)handwritingInfo to:(NSString *__nullable)roles onSuccess:(void (^__nullable)(void))onSuccess onFailure:(void (^__nullable)(NSError * _Nonnull error))onFailure;

/// 发送手写签名消息(这里使用的是 fabric3.4 方案
/// @param msg fabric3.4 方案 ，里面是绘制时候的路径的json字符格式的签名
/// @param roles 发送给的角色 string(clientId) = 会话中指定的⽤户 'customers' = 访客;'agents' = 坐席;'others' = 除了⾃⼰的所有⼈; 'all' =所有⼈
- (void)sendHandWritingMessage:(NSString * _Nullable)msg to:(NSString *__nullable)roles;

/// 获取本地视频流的快照
/// @param onSuccess 拍照成功
/// @param onFailure 失败
-(void)getSnapShotImage:(void (^)(UIImage*))onSuccess onFailure:(void (^)(NSError*))onFailure;

@end

NS_ASSUME_NONNULL_END
